﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using LiBLaB.Audio;

namespace PlayMP3
{
    public partial class MainFrm : Form
    {
        MP3 mp3;

        public MainFrm()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "MP3 Audio files (*.mp3)|*.mp3";
            if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
                mp3 = null;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(mp3 == null)
                mp3 = new MP3(textBox1.Text);
            mp3.Play();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            mp3.Pause();
        }

        private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
        {
           mp3.Dispose();
        }
    }
}
